﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Xml;
using System.Xml.Linq;

namespace Norbauer.Office.OneNote
{
    class XMLHelpers
    {
        public static Dictionary<string, string> getQuickStyleDefsFromPageXElement(XElement page, XNamespace ns)
        {
            // returns Dictionary<{quickStyleIndex number}, {element name}>
            // this allows you to tell what type of TextSpan you're working with
            // in case, for example, you want to target just paragraphs rather than headers.
            Dictionary<string, string> quickstyledefs = new Dictionary<string, string>();
            foreach (XElement e in page.Descendants(ns + "QuickStyleDef"))
            {
                quickstyledefs.Add(e.Attribute("index").Value, e.Attribute("name").Value);
            }
            return quickstyledefs;
        }
    }
}
